/**
 * project: finance-manage
 * package: com.example.models
 * 账单数据模型类
 */

package com.example.models;

import com.example.interfaces.BillDataInterface;

public class BillDataModel implements BillDataInterface {

    /**
     * Foods = 'foods',
     * Fuel = 'fuel',
     * Games = 'games',
     * Income = 'income',
     * Invest = 'invest',
     * Pets = 'pets',
     * Snacks = 'snacks',
     * Travel = 'travel'
     */
    public static enum BillType {
        Foods,
        Fuel,
        Games,
        Income,
        Invest,
        Pets,
        Snacks,
        Travel
    }

    /**
     * CREATE TABLE bills_default (
     * type VARCHAR(10) NOT NULL COMMENT '账单类型',
     * amount DECIMAL(10,2) NOT NULL COMMENT '账单金额',
     * date DATETIME NOT NULL COMMENT '账单日期时间',
     * statement VARCHAR(90) COMMENT '账单说明',
     * notes VARCHAR(150) COMMENT '备注'
     * );
     */
    private int bid;
    private String type;
    private double amount;
    private String date;
    private String statement;
    private String notes;

    public BillDataModel() {
    }

    public BillDataModel(JsonModel jsonModel) {
        this.type = (String) jsonModel.get("type");
        try {
            this.amount = (double) jsonModel.get("amount");
        } catch (java.lang.ClassCastException e) {
            this.amount = (double) (int) jsonModel.get("amount");
        }
        this.date = (String) jsonModel.get("date");
        this.statement = (String) jsonModel.get("statement");
        this.notes = (String) jsonModel.get("notes");
        Object tmp = jsonModel.get("bid");
        this.bid = tmp!= null ? (int) tmp : 0;
    }

    public BillDataModel(String type, double amount, String date, String statement, String notes) {
        this.type = type;
        this.amount = amount;
        this.date = date;
        this.statement = statement;
        this.notes = notes;
    }

    public BillDataModel(int bid, String type, double amount, String date, String statement, String notes) {
        this.bid = bid;
        this.type = type;
        this.amount = amount;
        this.date = date;
        this.statement = statement;
        this.notes = notes;
    }

    @Override
    public int getBid() {
        return this.bid;
    }

    @Override
    public String getType() {
        return this.type;
    }

    @Override
    public double getAmount() {
        return this.amount;
    }

    @Override
    public String getDate() {
        return this.date;
    }

    @Override
    public String getStatement() {
        return this.statement;
    }

    @Override
    public String getNotes() {
        return this.notes;
    }

    @Override
    public void setBid(int bid) {
        this.bid = bid;
    }

    @Override
    public void setType(String type) {
        this.type = type;
    }

    @Override
    public void setAmount(double amount) {
        this.amount = amount;
    }

    @Override
    public void setDate(String date) {
        this.date = date;
    }

    @Override
    public void setStatement(String statement) {
        this.statement = statement;
    }

    @Override
    public void setNotes(String notes) {
        this.notes = notes;
    }

}
